<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link href="{$NOW_THEME_URL}/Assets/css/style-metro.css" rel="stylesheet" type="text/css"/>
<script src="__PUBLIC__/Js/jquery.min.js" type="text/javascript"></script>
<script src="{$NOW_THEME_URL}/Assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=61E7222b2e4ef33a4bea3e66c12049b5"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
<link rel="stylesheet" href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" />
<script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.js"></script>
<link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.css" />
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/artdialog/jquery.artdialog.js?skin=bootstrap"></script>
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/artdialog/plugins/iframeTools.source.js"></script>
<title>设置地图标记</title>
<style type="text/css">
body, html{width: 100%;height: 100%;overflow: hidden;margin:0;}
#allmap {width: 100%;height: 93%;overflow: hidden;}
#allmap .anchorTR .BMapLib_marker {display: block;}
#allmap .anchorTR .BMapLib_circle {
	display: none;
}
#allmap .anchorTR .BMapLib_polygon {
	display: none;
}
#allmap .anchorTR .BMapLib_polyline {
	display: none;
}
#allmap .BMapLib_rectangle{
	display:none; BMapLib_last
}
#allmap .BMap_cpyCtrl, .location .anchorBL {
	display: none;
}
.button{
	text-align:right;
	padding:2px 10px;
	height:20px;
}
</style>
</head>
<body>
<input type="hidden" id="pointlng" name="pointlng" value=""/>
<input type="hidden" id="pointlat" name="pointlat" value=""/>
<div id="allmap" style="overflow:hidden;zoom:1;position:relative;">	
    <div id="map" style="height:95%;-webkit-transition: all 0.5s ease-in-out;transition: all 0.5s ease-in-out;"></div>
    <div id="showPanelBtn" style="position:absolute;font-size:14px;top:50%;margin-top:-95px;margin-right:20px;right:20px;width:20px;padding:10px 10px;"></div>
</div>
<div class="button">
<a class="btn blue" id="confirm" data-toggle="modal">
   <i class="icon-map-marker"></i> &nbsp;确定标记
</a>
</div>
</body>
<script type="text/javascript">
var map = new BMap.Map("allmap"); 

<empty name="row">
map.centerAndZoom(new BMap.Point(116.4035,39.915),12);
map.setCenter("{$address}");
map.setZoom(9);
<else />
var content = "<p>{$row.title}</p><p>{$row.address}</p>";	 
var point = new BMap.Point({$row.longitude},{$row.latitude});
var marker = new BMap.Marker(point);
var infoWindow = new BMap.InfoWindow(content);  // 创建信息窗口对象
map.centerAndZoom(point, 13);
map.addOverlay(marker);
marker.addEventListener("click", function(){          
   this.openInfoWindow(infoWindow);
});

</empty>


map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}));  //右上角，仅包含平移和缩放按钮
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN}));  //左下角，仅包含平移按钮
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));  //右下角，仅包含缩放按钮
map.addEventListener("click", function(e){
	//$('#r-result').html(e.point.lng + ", " + e.point.lat);
	$('#pointlat').val(e.point.lat);//纬度
	$('#pointlng').val(e.point.lng);//经度
});
//map.enableScrollWheelZoom();
var overlays = [];
var overlaycomplete = function(e){
	clearAll();
    overlays.push(e.overlay);
};
var drawingManager = new BMapLib.DrawingManager(map, {
    isOpen: false, //是否开启绘制模式
    enableDrawingTool: true, //是否显示工具栏
    drawingToolOptions: {
        anchor: BMAP_ANCHOR_TOP_RIGHT,
        offset: new BMap.Size(35, 20),
        scale: 0.8 
    }
});
drawingManager.addEventListener('overlaycomplete', overlaycomplete);

function clearAll() {
    for(var i = 0; i < overlays.length; i++){
        map.removeOverlay(overlays[i]);
    }
    overlays.length = 0
}
jQuery(document).ready(function() {
	$('#confirm').bind("click",function(){
		var origin = artDialog.open.origin;
		
		var pointlng = $('#pointlng').val();
		origin.$('#pointlng').val(pointlng);
		
		var pointlat = $('#pointlat').val();
		origin.$('#pointlat').val(pointlat);
		art.dialog.close();
	});
});
</script>
</html>
